package com.rrd.dw.mr.gzip.kafka;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.third.phonehelp.PHoneHelpPScoreRecord;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper.Context;

import java.io.IOException;

/**
 *电话邦电商行为子分
 *
 * @author rrz
 */


public class PHoneHelpPScoreParse  extends ParseBase {
    private Text val = new Text();
    private Text key = new Text();

    /**
     * 电话邦电商行为子分
     *
     * @param model
     * @throws IOException
     * @throws InterruptedException
     */
    public boolean parseJob(Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {

        PHoneHelpPScoreRecord obj = (PHoneHelpPScoreRecord)model;
        StringBuilder sb = getBaseInfo(obj, successful);

        //请求标识
        sb.append(obj.getSid()).append(CRT001);
        //电商行为子分
        sb.append(obj.getScore()).append(CRT001);
        StringBuilder txSb = getBaseInfo(obj);
        key.set(getKey());
        val.set((sb.toString() + txSb.toString()).replace("\n","").replace("\r", " "));
        context.write(key, val);
        return true;

    }

    @Override
    public String getTableName() {
        return "kafka_babel_phonehelp_pscore_inc";
    }

    @Override
    public String getType() {
        return RecordType.PHONE_HELP_PSCORE_RECORD.toString();
    }

    @Override
    public String getComment() {
        return "电话邦电商行为子分";
    }


}
